var downLink = "";
var videoLong;
function myDownloadfile(a,b,c) {
    $("#table").addClass("el-loading");
    downloadfile(a,b,c);
    setTimeout(function (){
        $("#table").removeClass("el-loading");
    },videoLong);
}
$(()=>{
    let $get = $("#get");
    let $inputbox = $("#inputbox");
    $inputbox.focus();
    let $main = $("#main");
    let $table = $("#table");
    let $item1 = $("#item1");
    let $item2 = $("#item2");
    let $item3 = $("#item3");
    let $item4 = $("#item4");
    let $item5 = $("#item5");
    let $item6 = $("#item6");
    $inputbox.keydown(e=>{if (e.keyCode===13)$get.click();});
    $(document).keydown(e=>{if(e.keyCode===36){if(e.ctrlKey){if(confirm("是否要返回上一页？")){location.href = "./?/index";}}else{if(confirm("是否要返回首页？")){history.back();}}}});
    $get.click(()=>{
        $main.addClass("el-loading");
        let id = $inputbox.val();
        $.post("#",{
            id:id
        },text=>{
            $main.removeClass("el-loading");
            $table.hide();
            $table.removeClass("el-loading");
            let data=JSON.parse(text);
            if (data.success){
                $item1.text(id);
                $item2.text(data.name);
                $item3.text(data.author);
                $item4.html(`<img src="${data.cover}" width="300">`);
                $item5.html(`<audio src="${data.mp3url}" controls>`);
                $item6.html(`<a href="${data.mp3url}" download="${data.mp3url}">${data.mp3url}</a>`);
                $table.fadeIn();
            }else {
                alert(data.message);
            }
            console.log(text);
        });
    });
});
